package IOperation;

import BOOK.Book;
import BOOK.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: wenxiwen
 * Date: 2022/4/14
 * Time: 20:31
 * Description: No Description
 */
public class Display implements IOperation{
    public void work(BookList bookList) {
        System.out.println("查找图书");

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入要查找的书籍名称：");
        String name = scan.nextLine();
        int index = bookList.getCount();
        for (int i = 0; i < index; i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equals(name)) {
                System.out.println("找到了信息如下：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有找到相关的书籍,请重试！");
    }
}